import './App.css'
import '@ant-design/v5-patch-for-react-19';
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
import AuthPage from './components/AuthPage';
import ChatPage from './components/ChatPage';
import AuthRoute from './components/AuthRoute';
import ChatContent from './components/Conversation';
import { isAuthenticated } from './utils/auth';

function App() {
  return (
    <Router>
      <Routes>
        <Route
        path="/chat-page"
        element={
          <AuthRoute>
            <ChatPage />
          </AuthRoute>
        }
      />
      <Route
        path="/"
        element={
          isAuthenticated() ? (
            <Navigate to="/chat" replace />
          ) : (
            <Navigate to="/login" replace />
          )
        }
      />
      <Route path="/login" element={<AuthPage />} />
      <Route
        path="/chat"
        element={
          <AuthRoute>
            <ChatContent />
          </AuthRoute>
        }
      />
      
    </Routes>
    </Router>
  );
}

export default App
